<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Python爬虫：健康打卡系统签到, blog">
    <meta name="description" content="这是我的个人网站，欢迎来访">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>Python爬虫：健康打卡系统签到 | 头号咸鱼</title>
    <link rel="icon" type="image/png" href="/favicon.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>

    <script>(function(i,s,o,g,r,a,m){i["DaoVoiceObject"]=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;a.charset="utf-8";m.parentNode.insertBefore(a,m)})(window,document,"script",('https:' == document.location.protocol ? 'https:' : 'http:') + "//widget.daovoice.io/widget/7b318e23.js","daovoice")</script>
    

<meta name="generator" content="Hexo 5.3.0">
<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
<link rel="alternate" href="/atom.xml" title="头号咸鱼" type="application/atom+xml">
</head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">头号咸鱼</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">头号咸鱼</div>
        <div class="logo-desc">
            
            这是我的个人网站，欢迎来访
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/blinkfox/hexo-theme-matery" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/blinkfox/hexo-theme-matery" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('https://cdn.jsdelivr.net/gh/liangxinxin5102/image2/cartoon01/wallhaven-j39rj5.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Python爬虫：健康打卡系统签到</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/%E7%88%AC%E8%99%AB/">
                                <span class="chip bg-color">爬虫</span>
                            </a>
                        
                            <a href="/tags/%E6%8E%A8%E8%8D%90/">
                                <span class="chip bg-color">推荐</span>
                            </a>
                        
                            <a href="/tags/%E6%8E%A2%E7%B4%A2/">
                                <span class="chip bg-color">探索</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/python%E7%88%AC%E8%99%AB/" class="post-category">
                                python爬虫
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2021-02-27
                </div>
                

                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-check fa-fw"></i>更新日期:&nbsp;&nbsp;
                    2021-02-27
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    3.8k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    14 分
                </div>
                

                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">

        
        <!-- 是否加载使用自带的 prismjs. -->
        <link rel="stylesheet" href="/libs/prism/prism.css">
        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="一、分析网站"><a href="#一、分析网站" class="headerlink" title="一、分析网站"></a>一、分析网站</h2><h4 id="1-初步观察登录"><a href="#1-初步观察登录" class="headerlink" title="1.初步观察登录"></a>1.初步观察登录</h4><h6 id="探索表单内容"><a href="#探索表单内容" class="headerlink" title="探索表单内容"></a>探索表单内容</h6><ol>
<li>我先查看元素，检查表单。（就是要往表单里填数据）</li>
</ol>
<blockquote>
<p>看了一下自己之前写的简阅电子书爬虫博客，上面没有详细介绍表单数据的截图类型。那个网站挂掉了，会员收费的，不怎么样，果然是收了钱就跑路，我当时<code>云短信</code>注册了十几个账号给自己kindle屯书，免费白嫖。现在抱着希望取看了一下，结果跳转到不良网站了（坑定是收费跑路的那种）。</p>
</blockquote>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222113503.png"></p>
<blockquote>
<p>我观察了一下，应该是<code>&lt;input&gt;</code>标签中的id来标记填入表单里面的内容。</p>
</blockquote>
<ol start="2">
<li>使用poseman发送get请求</li>
</ol>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222114851.png"></p>
<blockquote>
<p>可以看到这源码很全面简介，不多见。从这部分js可以看出表单获取的值，自己的猜测是对的。那么键值是username还是username1呢？有点纠结，解决办法就是随便填入数据，发送表单，查看post请求</p>
</blockquote>
<ol start="3">
<li>查看post请求的信息（关键）</li>
</ol>
<ul>
<li>点击到检查源代码的Network/XHR选项</li>
<li>填写登录信息，点击登录（乱填）。就可以看到只有一个psot请求，最下面就是表单内容</li>
</ul>
<blockquote>
<p><a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/index/login.do?currSchool=ctgu&amp;CURRENT_YEAR=2019&amp;showWjdc=false&amp;studentShowWjdc=false">http://yiqing.ctgu.edu.cn/wx/index/login.do?currSchool=ctgu&amp;CURRENT_YEAR=2019&amp;showWjdc=false&amp;studentShowWjdc=false</a></p>
</blockquote>
<ul>
<li>这是登录页面的地址</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222113354.png"></p>
<h6 id="结论"><a href="#结论" class="headerlink" title="结论"></a>结论</h6><ul>
<li>表单携带的内容是username和password，发送post请求登录时要带上</li>
</ul>
<h4 id="2-准备测试登录"><a href="#2-准备测试登录" class="headerlink" title="2.准备测试登录"></a>2.准备测试登录</h4><blockquote>
<p>使用psotman发送post请求，携带这两个参数，看看返回的内容。</p>
</blockquote>
<h6 id="探索尝试（错误）"><a href="#探索尝试（错误）" class="headerlink" title="探索尝试（错误）"></a>探索尝试（错误）</h6><blockquote>
<p>一般是按这个步骤做，但是这个网站不行。</p>
</blockquote>
<p><strong>猜测</strong>：登录后填入这条请求的cookie到postman中，请求头中加入cookie信息就可以得到页面</p>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222124304.png"></p>
<p><strong>尝试</strong>：观察cookie信息，<strong>登录界面</strong>刷新时会有这个GET请求</p>
<blockquote>
<p>也即使你访问这个网站，会先get请求把网页源码请求过来，浏览器解析源码，然后就是你看到的页面。</p>
</blockquote>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222124756.png"></p>
<h6 id="猜想"><a href="#猜想" class="headerlink" title="猜想"></a>猜想</h6><ul>
<li><p>这应该就是完整的GET请求了，这个cookie应该时浏览器自己构造的。</p>
</li>
<li><p>在浏览器中复制未登录的cookie，postman中发送Post请求是登录失败的页面，使用之前登录成功的cookie，发送psot请求时登录后的页面信息（很容易从HTML文档看出）。（关键）</p>
</li>
<li><p>这个地址：<a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/health/studentHis.do%E6%98%AF%E4%B8%8A%E6%8A%A5%E5%AE%8C%E6%88%90%E6%B5%8F%E8%A7%88%E5%99%A8%E5%8F%91%E9%80%81%E7%9A%84%E8%AF%B7%E6%B1%82%EF%BC%8Cpsotman%E4%B8%8A%E5%A4%8D%E5%88%B6%E5%B7%B2%E7%99%BB%E5%BD%95%E7%9A%84cookie%E4%BF%A1%E6%81%AF%EF%BC%8C%E7%84%B6%E5%90%8E%E5%8F%91%E9%80%81%EF%BC%8C%E5%BA%94%E8%AF%A5%E5%B0%B1%E6%98%AF%E4%B8%8A%E6%8A%A5%E4%BA%86%E5%90%A7%E3%80%82%E4%B8%8D%E7%9F%A5%E9%81%93cookie%E4%BF%9D%E5%AD%98%E5%A4%9A%E9%95%BF%E6%97%B6%E9%97%B4%EF%BC%8C%E6%98%8E%E5%A4%A9%E5%86%8D%E8%AF%95%E5%90%A7%E3%80%82%E5%90%8E%E9%9D%A2%E8%A6%81%E5%81%9A%E7%9A%84%E5%B0%B1%E6%98%AF%E5%A6%82%E4%BD%95%E8%AE%A9%E6%9E%84%E9%80%A0%E7%9A%84cookie%E6%9C%89%E6%95%88%E7%99%BB%E5%BD%95%E3%80%82%EF%BC%88%E7%8C%9C%E6%83%B3%EF%BC%89">http://yiqing.ctgu.edu.cn/wx/health/studentHis.do是上报完成浏览器发送的请求，psotman上复制已登录的cookie信息，然后发送，应该就是上报了吧。不知道cookie保存多长时间，明天再试吧。后面要做的就是如何让构造的cookie有效登录。（猜想）</a></p>
</li>
<li><p>上报完成后请求上报界面，应该返回的上报信息</p>
</li>
<li><p>上报完成后，代码运行的结果是上传记录的每条信息，如果真的上报不止要加cookie信息</p>
</li>
</ul>
<pre class="line-numbers language-none"><code class="language-none">import requests

headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
    "Cookie":"JSESSIONID=BD3DFF3E76439AB0084D28CC8E036C4C"
}
URL = "http://yiqing.ctgu.edu.cn/wx/health/studentHis.do"
res = requests.post(URL,headers = headers)
print(res.text)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h6 id="过程"><a href="#过程" class="headerlink" title="过程"></a>过程</h6><ul>
<li>自己还是看了一下别的博客，之前准备通过自己的知识硬写的，发现了是再js代码中发送post请求，axja，和axios差不多。这地方确实是自己没注意到的</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222170345.png"></p>
<ul>
<li><a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/index/login.do?currSchool=ctgu&amp;CURRENT_YEAR=2019&amp;showWjdc=false&amp;studentShowWjdc=false">http://yiqing.ctgu.edu.cn/wx/index/login.do?currSchool=ctgu&amp;CURRENT_YEAR=2019&amp;showWjdc=false&amp;studentShowWjdc=false</a></li>
<li><a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/index/loginSubmit.do%EF%BC%9A%E8%BF%99%E4%B8%AA%E6%98%AF%E7%9C%9F%E6%AD%A3%E6%90%BA%E5%B8%A6%E7%94%A8%E6%88%B7%E5%90%8D%E5%92%8C%E5%AF%86%E7%A0%81%E5%8F%91%E9%80%81Post%E7%9A%84%E7%BD%91%E5%9D%80">http://yiqing.ctgu.edu.cn/wx/index/loginSubmit.do：这个是真正携带用户名和密码发送Post的网址</a></li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210222172429.png"></p>
<ul>
<li><p>对的就是这个地址（我把用户名和密码修改了）</p>
</li>
<li><p>这波操作后，你构造的cookie就有效了</p>
</li>
</ul>
<h2 id="二、第二天"><a href="#二、第二天" class="headerlink" title="二、第二天"></a>二、第二天</h2><h4 id="1-上报页面"><a href="#1-上报页面" class="headerlink" title="1.上报页面"></a>1.上报页面</h4><h6 id="查找上报接口"><a href="#查找上报接口" class="headerlink" title="查找上报接口"></a>查找上报接口</h6><ul>
<li>这个是上报页面的网站：<a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/health/toApply.do">http://yiqing.ctgu.edu.cn/wx/health/toApply.do</a></li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223083625.png"></p>
<ul>
<li><p>使用postman携带已登录的cookie信息发送GET请求。可以得到这个界面，而且包含了已添加的信息。</p>
</li>
<li><p>这个地方可以查看原生界面</p>
</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223083947.png"></p>
<ul>
<li><p>js分析</p>
</li>
<li><p>这个就是加载配置信息，有了以登录的cookie，就可以加载出来</p>
</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223084219.png"></p>
<ul>
<li>百度地图api调用</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223084418.png"></p>
<ul>
<li>这个就是提交数据的AJAX</li>
<li>post请求地址：<a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/health/saveApply.do">http://yiqing.ctgu.edu.cn/wx/health/saveApply.do</a></li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223084553.png"></p>
<ul>
<li>f表单里面就是提交的数据</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223085318.png"></p>
<ul>
<li>将name和value填写成键值对的形式加入到post请求里面。</li>
</ul>
<table>
<thead>
<tr>
<th>name</th>
<th>value</th>
<th>注释</th>
</tr>
</thead>
<tbody><tr>
<td>ttoken</td>
<td>f6d47616-cdab-43b8-b1e1-0f0f67c02921</td>
<td>隐藏内容，待研究</td>
</tr>
<tr>
<td>province</td>
<td>湖北省</td>
<td></td>
</tr>
<tr>
<td>city</td>
<td>宜昌市</td>
<td></td>
</tr>
<tr>
<td>district</td>
<td>西陵区</td>
<td></td>
</tr>
<tr>
<td>adcode</td>
<td>443000</td>
<td></td>
</tr>
<tr>
<td>longitude</td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>latitude</td>
<td>0</td>
<td></td>
</tr>
<tr>
<td>sfqz</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>sfys</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>sfzy</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>sfgl</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>status</td>
<td>1</td>
<td></td>
</tr>
</tbody></table>
<ul>
<li><p>这应该是配置好的固定信息，其他form的input也要填入</p>
</li>
<li><p>姓名，日期是填好的，改不了。有些是hidden的，不知道要不要提交</p>
</li>
</ul>
<table>
<thead>
<tr>
<th>name</th>
<th>value</th>
<th>注释</th>
</tr>
</thead>
<tbody><tr>
<td>szdz</td>
<td>湖北省 宜昌市 西陵区</td>
<td></td>
</tr>
<tr>
<td>sjh</td>
<td>17671871459</td>
<td></td>
</tr>
<tr>
<td>lxrxm</td>
<td></td>
<td>紧急联系人，可以未空</td>
</tr>
<tr>
<td>lxrsjh</td>
<td></td>
<td>紧急联系电话，可以为空</td>
</tr>
<tr>
<td>sffrAm</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>sffrNoon</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td>sffrPm</td>
<td>否</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td>sffy</td>
<td>否</td>
<td>不良发反应</td>
</tr>
<tr>
<td>sfgr</td>
<td>否</td>
<td>确证</td>
</tr>
<tr>
<td>sffx</td>
<td>否</td>
<td>校园</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</tbody></table>
<blockquote>
<p>我先不填必填字段手机号发送psot请求，看看什么响应。</p>
</blockquote>
<ul>
<li>不填手机号码，其他都填，返回</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223092813.png"></p>
<h6 id="接口测试笔记"><a href="#接口测试笔记" class="headerlink" title="接口测试笔记"></a>接口测试笔记</h6><ul>
<li>ttoken字段是必须发送的，不然没有反应</li>
<li>勾选ttoken一个字段都说重复提交（只添totoken）</li>
<li>cookie每次失效后要重新构建，第一个psot使登录有效，第二个提交上报信息（猜测）</li>
</ul>
<h6 id="发现"><a href="#发现" class="headerlink" title="发现"></a>发现</h6><ul>
<li>原来<strong>每次get请求后的ttoken值不一样</strong>，可能是这个原因导致返回提交信息重复，写代码使post后还要get提取ttoken的值（每次get都不同）。</li>
</ul>
<h6 id="成功"><a href="#成功" class="headerlink" title="成功"></a>成功</h6><p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223095545.png"></p>
<blockquote>
<p>如果后端接受的数据不处理，手机号码格式不对都可能被保存。</p>
<p>提交后再get请求得不到ttoken的值</p>
</blockquote>
<ul>
<li>这个界面就是查看上报状态，写代码时候要用到</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210223101725.png"></p>
<h4 id="2-代码编写测试"><a href="#2-代码编写测试" class="headerlink" title="2.代码编写测试"></a>2.代码编写测试</h4><ul>
<li>写代get后的cookie，发送psot登录信息成功</li>
</ul>
<pre class="line-numbers language-none"><code class="language-none">import requests


#添加用户名和密码，发送psot请求的地址
urlPost_1 = "http://yiqing.ctgu.edu.cn/wx/index/loginSubmit.do"
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
    "Cookie":"6BB88FEF66493D1D0E5F7B89D02F1759"
}

# URL = "http://yiqing.ctgu.edu.cn/wx/health/studentHis.do"
# res = requests.post(URL,headers = headers)
# print(res.status_code)
def uPost_1():
    data = {
        "username":"2018171206",
        "password":"052818"
    }
    res = requests.post(urlPost_1,headers = headers ,data=data)
    print(res.text)
    
if __name__ == "__main__":
    uPost_1()
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<blockquote>
<p>rquests.post的data参数填写表单数据，json填写payload数据，刚开始搞混了。</p>
</blockquote>
<ul>
<li>我随意改了一下cookie的值，运行还是成功的，可见不需要第一下get，cookie也是自己随意编写的。可以登录后，这个cookie将作为参数用于后面的请求</li>
</ul>
<hr>
<ul>
<li><a target="_blank" rel="noopener" href="http://yiqing.ctgu.edu.cn/wx/health/main.do">http://yiqing.ctgu.edu.cn/wx/health/main.do</a></li>
<li>这个界面就是未上报，查看是否上报的状态</li>
</ul>
<p><img src="https://gitee.com/liangxinixn/blog002/raw/master/image01/20210224002105.png"></p>
<h6 id="问题"><a href="#问题" class="headerlink" title="问题"></a>问题</h6><ul>
<li>这个函数的cookie信息不和post登录的cookie一样</li>
</ul>
<pre class="line-numbers language-none"><code class="language-none">#这个函数的cookie信息不和post登录的cookie一样
# 暂时失败
def Status():
    res = requests.get(urlGet_1,headers = headers)
    demo = etree.HTML(res.text)
    sta = demo.xpath("/html/body/main/section/header/div[1]/span/text()")
    result = sta
    print(result)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h6 id="解决"><a href="#解决" class="headerlink" title="解决"></a>解决</h6><ul>
<li>post请求后，响应的数据会携带cookie。在上一个psot函数中更新表头的cookie</li>
</ul>
<pre class="line-numbers language-none"><code class="language-none">res = requests.post(urlPost_1,headers = headers ,data=data)
cookie = requests.utils.dict_from_cookiejar(res.cookies)<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<ul>
<li>参考地址：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/qiaoer1993/p/11714624.html">https://www.cnblogs.com/qiaoer1993/p/11714624.html</a></li>
</ul>
<ul>
<li>这是获取token的未上报的get请求也面，可以此来判断是否上报（省略）</li>
</ul>
<pre class="line-numbers language-none"><code class="language-none"><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>
<h4 id="3-最终效果"><a href="#3-最终效果" class="headerlink" title="3.最终效果"></a>3.最终效果</h4><blockquote>
<p>不知道自己创建的Cookie为什么不行，尝试获取psot后的cookie也不行。我去观察psotman中的cookie，发送了那几个请求，cookie一直没有变。真的解决不了自己的cookie为什么不行，把psotman中的cookie用在代码中都是畅通的。如果这个cookie第二天失效了，那么我写的代码就没有实际用途，是自己的一番探索结果，博客的学习意义还是很大的，自己也不准备去深究了。</p>
</blockquote>
<h2 id="三、总结"><a href="#三、总结" class="headerlink" title="三、总结"></a>三、总结</h2><blockquote>
<p>没有等到明天，我下午跑了一下代码。获取不到上报状态信息，也就是cookie失效了，那么这篇博客具有的是学习价值。前面是自己探索过程的过程，整理了一下，觉得不好，还是后面来总结一下自己的尝试过程，以及最后的代码和演示视频说明。</p>
</blockquote>
<h4 id="1-尝试过程"><a href="#1-尝试过程" class="headerlink" title="1.尝试过程"></a>1.尝试过程</h4><ol>
<li>开始get登录界面，查看一下需要填写的表单。我通过填写错误的登录信息登录，观察psot请求，找出了psot请求携带的表单信息。</li>
<li>使用postman添加登录信息发送表单，但是登录不成功，返回的还是登录界面。晚上我还在想为什么，难道到这里步就要放弃吗？这次代码，我准备通过自己的知识储备编写，晚上我还是搜了一下别人的博客。</li>
<li>看了博客，我发现post请求的地址不是登录网站，而是另外的接口，在页面的js代码中，使用AXJA发送的psot请求，我解决了这个问题。（现在想想，其实我看浏览器中的那个post请求，只关注了表单数据，这上面也有请求地址，自己没关注）</li>
<li>get请求携带cookie，psot请求也携带了cookie，使用post请求应该是让cookie生效，这个cookie应该是自己随意构建的。我尝试这个猜想，向<strong>上报记录界面</strong>发送psot请求，可以获取到想要页面。</li>
<li>然后研究上报信息，这一天是点击上报，看看浏览器中的post请求，好像没看出什么名堂，因为这个网站浏览器捕捉到的请求有些不一样，里面的axjx写的请求没捕捉到，不知道咋搞的。我通过js代码中的ajxa看出来请求地址，提交的数据是表单#f。然后我一一对比提取出来了，填写到postman发送请求。</li>
<li>结果一直返回说我重复提交，我<strong>只保留一项ttoken还说我重复提交</strong>（这里是个弃坑点），我很郁闷，不知道什么问题。但是通过我的探索，不知道怎么发现了每次的ttoken是不一样的（其过程又很多尝试，花了不少时间），然后我使用新的ttoken，提交数据成功。</li>
<li>那么可以写代码了，代码只有提交登录信息这个函数是成功的，其他都失败了。那么我的猜想是错误的，post发送自己构建的cookie并使其有效，后面应该会用到其他token。我观察浏览器中的请求token，有些是一直相同的，不相同的token是很长一大串。我有些不明白，但是我搜了一下，<strong>获取psot请求响应的token</strong>。果然可以获取，当然不一样。</li>
<li>然后我尝试把响应的cookie加到下一次请求中，结果还是失败。（这里postman中测试正常，写代码出现问题，就不知道什么原因了，而且postman中的cookie是相同的，<strong>这个原因我现在也不知道</strong>）</li>
<li>不知道到这里应该弃坑了，我还是把后面的函数写了，用postman登录后获取的token获取cookie。它能够让后面的请求都执行成功。</li>
</ol>
<h4 id="2-最终代码与讲解"><a href="#2-最终代码与讲解" class="headerlink" title="2.最终代码与讲解"></a>2.最终代码与讲解</h4><blockquote>
<p>我把Param中的<strong>值</strong>删除了部分，不是<strong>键值对</strong>。</p>
</blockquote>
<pre class="line-numbers language-python" data-language="python"><code class="language-python">import requests
from lxml import etree

#添加用户名和密码，发送psot请求的地址
urlPost_1 = "http://yiqing.ctgu.edu.cn/wx/index/loginSubmit.do"
#提交上报数据，发送psot请求
urlPost_2 = "http://yiqing.ctgu.edu.cn/wx/health/saveApply.do"
#查看是否上报信息
urlGet_1 = "http://yiqing.ctgu.edu.cn/wx/health/main.do"
# 获取ttoken的地址
urlGet_2 = "http://yiqing.ctgu.edu.cn/wx/health/toApply.do"
headers = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
    "Cookie":"JSESSIONID=48F6B61431846C46A6D0B1DBE0760963"
}

headers2 = {
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36",
#     "Connection":"keep-alive",
#     "Referer":"http://yiqing.ctgu.edu.cn/wx/index/main.do",
#     "Upgrade-Insecure-Requests":"1",
    "Cookie":"JSESSIONID=48F6B61431846C46A6D0B1DBE0760963"
}

Param = {
        'ttoken':'e38d285f-aa-b03e-aa157c07de7d',
        'province':'省',
        'city':'市',
        'district':'区',
        'adcode':'400',
        'longitude':'0',
        'latitude':'0',
        'sfqz':'否',
        'sfys':'否',
        'sfzy':'否',
        'sfgl':'否',
        'status':'1',
        'szdz':'省 市 区',
        'sjh':'178719',
        'sffrAm':'否',
        'sffrNoon':'否',
        'sffrPm':'否',
        'sffy':'否',
        'sfgr':'否',
        'sffx':'否',
}
# URL = "http://yiqing.ctgu.edu.cn/wx/health/studentHis.do"
# res = requests.post(URL,headers = headers)
# print(res.status_code)


# 让cookie信息有效
def uPost_1():
    data = {
        "username":"2018171206",
        "password":"052818"
    }
    res = requests.post(urlPost_1,headers = headers ,data=data)
    
    #字典类型 {'JSESSIONID': '9948B4E502F692093224380BD8239A09'}
    cookie = requests.utils.dict_from_cookiejar(res.cookies)
    #headers2["Cookie"] = cookie['JSESSIONID']
    print(res.text)

#这个函数的cookie信息不和post登录的cookie一样
# 暂时失败
# 获取上一个psot的cookie还是失败
def Status():
    res = requests.get(urlGet_1,headers = headers2)
    demo = etree.HTML(res.text)
    sta = demo.xpath("/html/body/main/section/header/div[1]/span/text()")
    result = sta
    print(result)

def getToken():
    res = requests.get(urlGet_2,headers = headers2)
    demo = etree.HTML(res.text)
    ttoken = demo.xpath('//*[@id="f"]/input[1]/@value')
    Param["ttoken"] = ttoken[0]
    print(ttoken)
    
    
def Submit():
    res = requests.post(urlPost_2,headers=headers,data=Param)
    print(res.text)
# def uPost_2():

    

if __name__ == "__main__":
    uPost_1()
    Status()
    getToken()
    Submit()
<span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<ul>
<li>uPost_1()：提交登录信息，让自己构造的cookie有效（其实没效），获取相应的cookie(没用)</li>
<li>Status()：获取上报历史页面的上报信息，就是获取返回页面的一个标签中的字符出。</li>
<li>getToken()：get上报信息填写界面，获取新鲜的ttoken，加入到自己的上报psot请求中。</li>
<li>Submit()：提交上报信息</li>
</ul>
<h4 id="3-演示视频解释"><a href="#3-演示视频解释" class="headerlink" title="3.演示视频解释"></a>3.演示视频解释</h4><blockquote>
<p>没有录第二天的演示视频，因为提前发现失败了，cookie没过一天就无效了。</p>
</blockquote>
<ol>
<li>第一次运行，注释掉最后一个函数，也就是不会提交。输出登录成功，上报未成功状态以及新鲜的ttoken。这里的cookie是psotman提交登录信息成功后的cookie值</li>
<li>第二次运行，取消注释，最提提交成功。</li>
<li>第三次运行，可以登录成功，获取到已经上报的状态。因为上报完成，后面的接口返回的信息不一样，所以直接报错。</li>
</ol>
<p><strong>说明</strong>：演示视频是为了说明自己的代码是成功的，写这么多不搞个演示视频感觉不好，上划了一下把自己的部分个人信息透露了，还是取剪辑处理一下吧。（好吧不处理了）</p>
<p><strong>视频地址</strong>：<a target="_blank" rel="noopener" href="https://github.com/xinxinliang/codeSource/blob/master/00_%E9%A1%B9%E7%9B%AE%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91/01_%E7%96%AB%E6%83%85%E4%B8%8A%E6%8A%A5%E4%BB%A3%E7%A0%81%E6%BC%94%E7%A4%BA.mp4">https://github.com/xinxinliang/codeSource/blob/master/00_%E9%A1%B9%E7%9B%AE%E6%BC%94%E7%A4%BA%E8%A7%86%E9%A2%91/01_%E7%96%AB%E6%83%85%E4%B8%8A%E6%8A%A5%E4%BB%A3%E7%A0%81%E6%BC%94%E7%A4%BA.mp4</a></p>
<blockquote>
<p>先不上传到b站，上传到github把。</p>
</blockquote>
<h4 id="4-总结"><a href="#4-总结" class="headerlink" title="4.总结"></a>4.总结</h4><ol>
<li>可能是里的什么ajax请求太多了，cookie每次都要更新，要达到效果要把里面的请求都实现一遍，环环获取cookie才行。但是，还是不得不相信每次cookie是相同的（自己代码验证了这一点），但为什么代码中的构建cookie不行呢？<strong>非常不甘心，但不得不弃坑</strong></li>
<li>这个过程弃坑点还是有的，探索过程不那么容易，最后走到那一步也算是成功的，虽然不完美，自己还想如果可以自动上报，就再写发送邮件提醒的功能，现在到此为止吧。</li>
</ol>
<h4 id="5-最后"><a href="#5-最后" class="headerlink" title="5.最后"></a>5.最后</h4><ul>
<li>最后我就是在postman上面发送登录post，然后把cookie复制到代码中，然后执行代码完成上报</li>
</ul>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/about" rel="external nofollow noreferrer">lxx</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://xinxinliang.github.io/2021/02/27/python-pa-chong-jian-kang-da-qia-xi-tong-qian-dao/">http://xinxinliang.github.io/2021/02/27/python-pa-chong-jian-kang-da-qia-xi-tong-qian-dao/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/about" target="_blank">lxx</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/%E7%88%AC%E8%99%AB/">
                                    <span class="chip bg-color">爬虫</span>
                                </a>
                            
                                <a href="/tags/%E6%8E%A8%E8%8D%90/">
                                    <span class="chip bg-color">推荐</span>
                                </a>
                            
                                <a href="/tags/%E6%8E%A2%E7%B4%A2/">
                                    <span class="chip bg-color">探索</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="https://gitee.com/liangxinixn/guitar/raw/master/image01/20200726220206.png" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="https://gitee.com/liangxinixn/guitar/raw/master/image01/20200726220308.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2021/02/27/pyhton-pa-chong-mzitu-pa-qu-suo-you-tu-pian/">
                    <div class="card-image">
                        
                        <img src="https://cdn.jsdelivr.net/gh/liangxinxin5102/image2/cartoon01/wallhaven-j381v5.jpg" class="responsive-img" alt="Pyhton爬虫：mzitu爬取所有图片">
                        
                        <span class="card-title">Pyhton爬虫：mzitu爬取所有图片</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2021-02-27
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/python%E7%88%AC%E8%99%AB/" class="post-category">
                                    python爬虫
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E7%88%AC%E8%99%AB/">
                        <span class="chip bg-color">爬虫</span>
                    </a>
                    
                    <a href="/tags/%E6%8E%A8%E8%8D%90/">
                        <span class="chip bg-color">推荐</span>
                    </a>
                    
                    <a href="/tags/%E6%8E%A2%E7%B4%A2/">
                        <span class="chip bg-color">探索</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2021/02/27/python-pa-chong-jian-yue/">
                    <div class="card-image">
                        
                        <img src="https://cdn.jsdelivr.net/gh/liangxinxin5102/image2/cartoon01/wallhaven-j38xlw.png" class="responsive-img" alt="Python爬虫：简阅">
                        
                        <span class="card-title">Python爬虫：简阅</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2021-02-27
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/python%E7%88%AC%E8%99%AB/" class="post-category">
                                    python爬虫
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E7%88%AC%E8%99%AB/">
                        <span class="chip bg-color">爬虫</span>
                    </a>
                    
                    <a href="/tags/%E8%AE%B0%E5%BD%95/">
                        <span class="chip bg-color">记录</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('120')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + '来源: 头号咸鱼<br />'
            + '文章作者: lxx<br />'
            + '文章链接: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='false'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2021</span>
            
            <span id="year">2021</span>
            <a href="/about" target="_blank">lxx</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">272.8k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/xinxinliang" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:1974733812@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1974733812" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1974733812" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    
    <script>
        (function (i, s, o, g, r, a, m) {
            i["DaoVoiceObject"] = r;
            i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments)
            }, i[r].l = 1 * new Date();
            a = s.createElement(o), m = s.getElementsByTagName(o)[0];
            a.async = 1;
            a.src = g;
            a.charset = "utf-8";
            m.parentNode.insertBefore(a, m)
        })(window, document, "script", ('https:' == document.location.protocol ? 'https:' : 'http:') +
            "//widget.daovoice.io/widget/6984b559.js", "daovoice")
        daovoice('init', {
            app_id: "7b318e23"
        });
        daovoice('update');
    </script>
    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
